﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RuoVea.GoFastdfs.Common
{
    /// <summary>
    /// 接口响应
    /// </summary>
    public class ResponseBean
    {
        public static int SUCCESS_CODE = 200;
        public static int ERROR_CODE = 500;

        public int code { get; set; }
        public String msg { get; set; }
        public Object data { get; set; }

        public ResponseBean(int code, String msg, Object data)
        {
            this.code = code;
            this.msg = msg;
            this.data = data;
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <returns>ResponseBean</returns>
        public static ResponseBean success()
        {
            return new ResponseBean(SUCCESS_CODE, "success", "");
        }

        /// <summary>
        /// 成功,附加数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ResponseBean success(Object data)
        {
            return new ResponseBean(SUCCESS_CODE, "success", data);
        }

        /// <summary>
        /// 成功,附加信息及数据
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ResponseBean success(String msg, Object data)
        {
            return new ResponseBean(SUCCESS_CODE, msg, data);
        }

        /// <summary>
        /// 失败,附加信息及数据
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ResponseBean fail(String msg, Object data)
        {
            return new ResponseBean(ERROR_CODE, msg, data);
        }

        /// <summary>
        /// 失败,附加信息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ResponseBean fail(String msg)
        {
            return new ResponseBean(ERROR_CODE, msg, "");
        }
    }
}
